package com.gexin.model.order;

import com.gexin.model.order.base.BaseOrderRefundApply;

/**
 * 业务名称: t_order_refund_apply()
 */
@SuppressWarnings("serial")
public class OrderRefundApply extends BaseOrderRefundApply<OrderRefundApply> {
	public static final OrderRefundApply dao = new OrderRefundApply();
	public static final int State_Finsh = 5;
	/** 11同意退款申请，待用户填写退货快递单 */
	public static final int State_adrr_apply = 11;
	/** 12买家已提交退货物流，待商家收货确认退款 */
	public static final int State_return_goods = 12;

	/**
	 * xu 2016-07-28 通过item_id 来获取对应的退款信息
	 */
	public OrderRefundApply getOrderRefundApplyByItemId(String item_id) {
		String sql = "select i.*,d.product_id,p.product_name  from  t_order_refund_apply as i LEFT JOIN  t_order_item  as d  on i.item_id=d.item_id LEFT JOIN t_products as p  on d.product_id=p.id   where i.item_id=? order  by i.createtime desc";
		return dao.findFirst(sql, item_id);
	}

	/**
	 * 根据订单ID查询退款订单是否含运费
	 * @param isAddfreight
	 * @param orderId
	 * @return
	 */
	public OrderRefundApply findByOrderIsAddFreight(Integer isAddfreight, String orderId) {
		return dao.findFirst("select * from t_order_refund_apply where is_add_freight=? and order_id=?",isAddfreight,orderId);
	}

}
